<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								商户编号：<input type="text" name="userId"/>
							</li>
							<li>
								申请状态：<select name="sTATUS" th:with="type=${@dict.getType('money_status')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>

							<li class="select-time">
								<label>创建时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>

							<li>
								<a id="btnSearch"  class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-warning" onclick="$.table.exportExcel()">
		            <i class="fa fa-download"></i> 导出
		        </a>
		         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		        <font><b>提现总金额：</b><span id="spanSumMoney" > </span>元</font>
	        </div>
			
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
    	var statusType = [[${@dict.getType('money_status')}]];
    	var moneyChange = [[${@dict.getType('moneyChange_status')}]];
    	var removeFlag = [[${@permission.hasPermi('system:hatchetMoneyChange:edit')}]];
        var prefix = ctx + "system/hatchetMoneyChange";

        $(function() {
        	//点击总金额清零
        	$("#btnSearch").click(function(){
        		$("#spanSumMoney").text(0);
        	});
            var options = {
                url: prefix + "/list",
				exportUrl: prefix + "/export",
                modalName: "提现记录",
				search: false,
		        showExport: false,
               	columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '主键id',
					visible: false
				},
				{
					field : 'userId', 
					title : '商户编号',
					sortable: true
				},
			
				{
					field : 'merType', 
					title : '商户类型',
					align : 'left',
					formatter: function(value, item, index) {
						if(item.sumMoney != null){
	            			$("#spanSumMoney").text(item.sumMoney);
	            		} 
	            		return $.table.selectDictLabel(moneyChange, item.merType);
	            	} 
				},
				{
					field : 'merName', 
					title : '商户名称',
					sortable: false
				},
				{
					field : 'createTime', 
					title : '创建时间',
					sortable: true
				},
				{
					field : 'trxAmt', 
					title : '申请金额(元)',
					sortable: true
				},
				{
					field : 'status', 
					title : '申请状态',
					align : 'left',
					formatter: function(value, item, index) {
	            		return $.table.selectDictLabel(statusType, item.status);
	            	} 
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	if (row.status == '10B'){
		            		 actions.push('<a class="btn btn-success btn-xs ' + removeFlag + '" href="#" onclick="agree(\'' + row.id + '\')">审核通过</a>');
		            		 actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="refuse(\'' + row.id + '\')">审核拒绝</a>');
		            	}else {
		            		if (row.status == '10C'){
		            			actions.push('<a class="btn btn-success btn-xs ' + removeFlag + '" href="#"></i>已审核通过</a>');
		            		}else{
		            			actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#"></i>已审核拒绝</a>');
		            		}
		            	}
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        
        
        /* 提现管理-同意 */
		function agree(id) {
			$.modal.confirm("确认审核通过？", function() {
				$.operate.post(prefix + "/agreeStatus", { "iD": id, "sTATUS": '10C' });
		    })
		}
		 /* 提现管理-拒绝 */
		function refuse(id) {
			$.modal.confirm("确认审核拒绝？", function() {
				$.operate.post(prefix + "/refuseStatus", { "iD": id, "sTATUS": '10A' });
		    })
		}
    </script>
</body>
</html>